package com.cheetah.start.system.common.service;

import cn.hutool.core.io.resource.ClassPathResource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.nio.charset.StandardCharsets;

/**
 * @author Feel
 * @date 2021/11/10 19:16
 * @Description:
 */
@Slf4j
@Service
public class CommonService {

    @Value("${spring.profiles.active}")
    private String active;

    public void showYml() {
        String base = "application.yml";
        String dev = "application-dev.yml";
        String pro = "application-pro.yml";
        ClassPathResource resource = new ClassPathResource(base);
        String readStr = resource.readStr(StandardCharsets.UTF_8);
        String another = "";
        if ("dev".equals(active)) {
            another = dev;
        }
        if ("pro".equals(active)) {
            another = pro;
        }
        ClassPathResource resourceOther = new ClassPathResource(another);
        String readStrOther = resourceOther.readStr(StandardCharsets.UTF_8);
        log.info("\n" + readStr);
        log.info("\n" + readStrOther);
    }
}
